package com.kma.summer2012.client.view.manager;


import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.kma.summer2012.client.constants.ConstantsPresenter;
import com.kma.summer2012.client.presenters.manager.ManageWorksPresenter;
import com.kma.summer2012.client.styles.style2.Recources;
import com.smartgwt.client.widgets.tree.TreeGrid;


/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 12.02.13
 * Time: 20:27
 * To change this template use File | Settings | File Templates.
 */
public class ManageWorksView extends Composite implements ManageWorksPresenter.Display {

    interface ManageWorksViewUiBinder extends UiBinder<Widget, ManageWorksView> {
    }

    private static ManageWorksViewUiBinder ourUiBinder = GWT.create(ManageWorksViewUiBinder.class);

    @UiField
    protected Button addWorkButton;
    @UiField
    protected Button addCategoryButton;
    @UiField
    protected Button deleteWorkButton;
    @UiField
    protected Button backButton;
    @UiField
    protected Button editButton;
    @UiField
    protected TreeGrid catalog;
    @UiField
    protected Label workCatalog;


    public static ConstantsPresenter constants;

    @Override
    public HasClickHandlers getAddWorkButton() {
        return addWorkButton;
    }

    @Override
    public HasClickHandlers getAddCategoryButton() {
        return addCategoryButton;
    }

    @Override
    public HasClickHandlers getDeleteWorkButton() {
        return deleteWorkButton;
    }

    @Override
    public HasClickHandlers getBackButton() {
        return backButton;
    }

    @Override
    public HasClickHandlers getEditButton() {
        return editButton;
    }


    @Override
    public TreeGrid getTreeGrid() {
        return catalog;
    }

    @Override
    public Widget asWidget() {
        return this;
    }

    @Override
    public void setDelEnable(boolean enable) {
        this.deleteWorkButton.setEnabled(enable);
    }

    @Override
    public void setEditEnable(boolean enable) {
        this.editButton.setEnabled(enable);
    }

    public ManageWorksView() {
        constants = GWT.create(ConstantsPresenter.class);

        HTMLPanel rootElement = (HTMLPanel) ourUiBinder.createAndBindUi(this);
        /*catalog.addStyleName(Recources.INSTANCE.styles().imgHeaderButtonCatalog());
        catalog.addStyleName(Recources.INSTANCE.styles().headerButtonCatalog());
        catalog.addStyleName(Recources.INSTANCE.styles().imgHeaderButtonSelectedCatalog());
        catalog.addStyleName(Recources.INSTANCE.styles().headerButtonSelectedCatalog());*/
       /* catalog.setStyleName(Recources.INSTANCE.styles().imgHeaderButton());
        catalog.setStyleName(Recources.INSTANCE.styles().headerButton());
        catalog.setStyleName(Recources.INSTANCE.styles().imgHeaderButtonSelected());
        catalog.setStyleName(Recources.INSTANCE.styles().headerButtonSelected());  */
        //catalog.setStyleName(Recources.INSTANCE.styles().ShowCatalogTable());
        addWorkButton.setStyleName(Recources.INSTANCE.styles().Caption());
        addCategoryButton.setStyleName(Recources.INSTANCE.styles().Caption());
        deleteWorkButton.setStyleName(Recources.INSTANCE.styles().Caption());
        editButton.setStyleName(Recources.INSTANCE.styles().Caption());
        backButton.setStyleName(Recources.INSTANCE.styles().Caption());
        workCatalog.setStyleName(Recources.INSTANCE.styles().titleCatalog());

        workCatalog.setText(constants.WORK_CATALOG());
        // this.deleteWorkButton.setEnabled(false);
        editButton.setEnabled(false);
        deleteWorkButton.setEnabled(false);
        initWidget(rootElement);
    }

}